package com.tiantianfresh.model.dao;

import com.tiantianfresh.model.pojo.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

/**
 * @author FANGAO
 * @date 2021/12/1 - 上午 11:52
 */
public interface ShoppingCartMapper extends Mapper<ShoppingCart> {
    @Select("select * from r_shopping_cart where userid=#{id}")
    List<ShoppingCart> queryShoppingCartAll(@Param("id") Integer id);

    @Delete("delete from r_shopping_cart where scid=#{id}")
    int deleteShoppingCart(@Param("id")Integer id);

    int deleteShoppingCarts(Map<String, Integer[]> map);

    @Update("update r_shopping_cart set shoppingCartQuantity=#{shoppingCartQuantity} where scid = #{id}")
    int updateQuantity(Map<String, Integer> map);

    @Select("select shoppingCartQuantity from r_shopping_cart where scid = #{id}")
    int selectQuantityid(@Param("id") Integer id);

    @Update("update r_shopping_cart set shoppingCartState=#{state} where scid = #{id}")
    int updeatState(Map<String, Integer> map);

    @Select("select * from r_shopping_cart where userid = #{userid} and shoppingCartName=#{commodityname} and shoppingCartWeight=#{company}")
    ShoppingCart selectShoppingCartCount(@Param("commodityname") String commodityname,@Param("company") String company,@Param("userid") Integer userid);

    @Select("select * from r_shopping_cart where userid=#{id} and shoppingCartState=1")
    List<ShoppingCart> queryShoppingCartState(Integer userid);

    @Update("update r_shopping_cart set shoppingCartState= 0 where userid = #{userid}")
    int initializationState(Map<String, Integer> map);
}
